/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package com.lineage.server.model.item.etcitem.action;

import static com.lineage.server.model.skill.L1SkillId.AWAKEN_ANTHARAS;
import static com.lineage.server.model.skill.L1SkillId.AWAKEN_FAFURION;
import static com.lineage.server.model.skill.L1SkillId.AWAKEN_VALAKAS;

import com.lineage.server.PacketCreate;
import com.lineage.server.model.L1PolyMorph;
import com.lineage.server.model.Instance.L1ItemInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.item.ItemExecutor;

/**
 * Class <code>PolyScrollShinerLV52</code> 夏纳的变身卷轴(52级) - 49151.
 * 
 * @author jrwz
 * @version 2012-6-21下午10:24:55
 * @see com.lineage.server.model.item.etcitem.action
 * @since JDK1.7
 */
public final class PolyScrollShinerLV52 extends ItemExecutor {

    /**
     * 取得实例.
     * 
     * @return 实例
     */
    public static ItemExecutor get() {
        return new PolyScrollShinerLV52();
    }

    /** 夏纳的变身卷轴(52级) - 49151. */
    private PolyScrollShinerLV52() {
    }

    @Override
    public void execute(final L1PcInstance pc, final L1ItemInstance useItem,
            final int readC1, final int readC2, final int targetId,
            final int targetX, final int targetY) {
        // 不能变身的状态
        // 取回觉醒技能ID
        final int awakeSkillId = pc.getAwakeSkillId();
        if ((awakeSkillId == AWAKEN_ANTHARAS)
                || (awakeSkillId == AWAKEN_FAFURION)
                || (awakeSkillId == AWAKEN_VALAKAS)) {
            PacketCreate.get().sendSinglePackets(pc, "目前状态中无法变身");
            return;
        }

        // 变身时间 (秒)与变身编号
        short polyId = 0;
        final short time = 1800;
        final byte sex = pc.get_sex(); // 角色性别

        switch (sex) {
            case 0:
                if (pc.isCrown()) {
                    polyId = 6842;
                } else if (pc.isKnight()) {
                    polyId = 6844;
                } else if (pc.isElf()) {
                    polyId = 6846;
                } else if (pc.isWizard()) {
                    polyId = 6848;
                } else if (pc.isDarkelf()) {
                    polyId = 6850;
                } else if (pc.isDragonKnight()) {
                    polyId = 7147;
                } else if (pc.isIllusionist()) {
                    polyId = 7149;
                }
                break;
            case 1:
                if (pc.isCrown()) {
                    polyId = 6843;
                } else if (pc.isKnight()) {
                    polyId = 6845;
                } else if (pc.isElf()) {
                    polyId = 6847;
                } else if (pc.isWizard()) {
                    polyId = 6849;
                } else if (pc.isDarkelf()) {
                    polyId = 6851;
                } else if (pc.isDragonKnight()) {
                    polyId = 7148;
                } else if (pc.isIllusionist()) {
                    polyId = 7150;
                }
                break;
            default:
                break;
        }
        L1PolyMorph.doPoly(pc, polyId, time, L1PolyMorph.MORPH_BY_ITEMMAGIC);
        pc.getInventory().removeItem(useItem, 1); // 删除道具
    }
}
